package com.example.testapp.activity.view.dialog;

import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import com.example.testapp.R;

/**
 * Created by l on 2016/8/30.
 */
public class CustomExitDialog extends Dialog {

    public int layoutRes;
    public Context context;
    public Activity mActivity;
    public Button   confirmBtn; /** 确定按钮 **/
    public Button   cancelBtn; /** 取消按钮 **/

    public CustomExitDialog(Context context) {
        super(context);
        this.context = context;
        mActivity = (Activity) context;
    }

    /**
     * 自定义布局的构造方法
     *
     * @param context
     * @param resLayout
     */
    public CustomExitDialog(Context context, int resLayout) {
        super(context, resLayout);
        this.context = context;
        this.layoutRes = resLayout;
        mActivity = (Activity) context;
    }

    /**
     * 自定义主题及布局的构造方法
     *
     * @param context
     * @param theme
     * @param resLayout
     */
    public CustomExitDialog(Context context, int theme, int resLayout) {
        super(context, theme);
        this.context = context;
        this.layoutRes = resLayout;
        mActivity = (Activity) context;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.setContentView(layoutRes);
        confirmBtn = (Button)findViewById(R.id.confirm_btn);
        cancelBtn = (Button)findViewById(R.id.cancel_btn);

        confirmBtn.setTextColor(0xff1E90FF);
        cancelBtn.setTextColor(0xff1E90FF);

        confirmBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mActivity.finish();
               // System.exit(0);
            }
        });

        cancelBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
    }
}
